import { Action } from '@ngrx/store';
/**
 * 控制主应用的propup
 */

/**
 * 消息模型
 */
export interface MsgState {
    message: string,
    title: string
}

/**
 * 动作
 */
export interface MsgAction extends Action {
    type: string,
    data?: MsgState
}

/**
 * MsgTableIfce
 */
interface MsgTableIfce {
    (state: MsgState, action: MsgAction): MsgState;
}

/**
 * MsgTable
 */
export const MsgTable: MsgTableIfce = (state: MsgState = { message: '', title: '警告' }, action: MsgAction = { type: '' }) => {

    switch (action.type) {
        case 'send': state = action.data ? action.data : state; break;
    }

    return Object.assign({}, state);
}